package com.lsfb.signln.Statistics.HistoryRecord;

import android.content.Context;
import android.widget.TextView;

import com.lsfb.signln.R;
import com.lsfb.signln.Utils.URLString;
import com.zgscwjm.lsfbbasetemplate.adapter.CommonRecycAdapter;
import com.zgscwjm.lsfbbasetemplate.adapter.ViewHolderRecyc;
import com.zgscwjm.lsfbbasetemplate.utils.T;

import java.util.List;

/**
 * Created by Administrator on 2018/2/28 0028.
 */

public class HistoryRecordAdapter extends CommonRecycAdapter<HistoryRecordBean.ListBean> {
    private Context mContext;

    public HistoryRecordAdapter(Context context, List<HistoryRecordBean.ListBean> list, int layoutId) {
        super(context, list, layoutId);
        mContext = context;
    }

    @Override
    public void convert(ViewHolderRecyc holder, HistoryRecordBean.ListBean model) {
        //姓名
        holder.setText(R.id.tv_name, model.getName());
        //地址
        holder.setText(R.id.tv_address, model.getProvinces() + "  " + model.getCity());
        //时间
        holder.setText(R.id.tv_time, model.getTime());

        //类型
        String type;

        String signState = String.valueOf(model.getSignState());
        TextView tv_type = holder.getView(R.id.tv_type);
        if (signState.equals("0")) {
            type = "内勤";
            tv_type.setTextColor(mContext.getResources().getColor(R.color.label_forgive));
        } else {
            type = "外勤";
            tv_type.setTextColor(mContext.getResources().getColor(R.color.theme_color));
        }
        tv_type.setText(type);

        //种类
        String signType = String.valueOf(model.getSignType());
        if (signType.equals("0")) {     //人脸识别
            holder.setVisible(R.id.iv_retroactive, false);
            holder.setVisible(R.id.ll_signature, false);
        } else if (signType.equals("1")) {      //文字
            holder.setVisible(R.id.iv_retroactive, false);
            holder.setVisible(R.id.ll_signature, true);
            if (model.getSignPath() != null) {
                holder.setImg(R.id.iv_signature, URLString.IMAGES + model.getSignPath(), 0);
            } else {
                T.showShort(mContext, "没有签名");
            }
        } else if (signType.equals("2")) {      //补签
            holder.setVisible(R.id.iv_retroactive, true);
            holder.setVisible(R.id.ll_signature, false);
        }
    }
}
